FROM node:alpine AS build

MAINTAINER genghongliang

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

# 构建 TypeScript 代码
RUN npm run build && \
    # 删除不必要的文件（根据实际项目调整）
    rm -rf .next/static/*.map ./.gitignore ./.next/cache  ./src ./public ./tests ./coverage

FROM node:alpine

ENV TZ=PRC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

WORKDIR /app

COPY --from=build /app ./

# 暴露 3001 端口
EXPOSE 3000

CMD ["npm", "start"]
